// 维修工单
import {
	request_post
} from '@/api/request.js'

import {
	getData
} from '@/tools/tools.js'

// 获取维修单 列表
export const getMaintainList = () => {
	return request_post('/repair_orders_list', {
		user_id: getData().id,
	})
}

// 获取维修单详情
export const getMaintainConfig = (from) => {
	let rec_id = from
	return request_post('/ticket_details_fields', {
		user_id: getData().id,
		record_id: rec_id
	})
}

// 获取维修单详情照片
export const getMaintainPhotosList = (from) => {
	let rec_id = from
	return request_post('/ticket_details_photos', {
		user_id: getData().id,
		record_id: rec_id
	})
}

// 获取维修单领用详情
export const getReceiveXiangqing = (from) => {
	let rec_id = from
	return request_post('/ticket_details_spare_parts', {
		user_id: getData().id,
		record_id: rec_id
	})
}

// 维修单保存按钮
export const saveMaintainData = (from) => {
	let rec_id = from.id
	let fix_desc = from.fix_desc
	let internal_notes = from.internal_notes
	let repair_detail = from.repair_detail
	return request_post('/update_valus', {
		user_id: getData().id,
		record_id: rec_id,
		fix_desc: fix_desc,
		internal_notes: internal_notes,
		repair_detail: repair_detail,
	})
}


// 维修单完成按钮
export const saveDone = (from) => {
	let rec_id = from
	return request_post('/done_button', {
		user_id: getData().id,
		record_id: rec_id
	})
}

// 检验完成状态
export const saveJianyanWancheng = (from) => {
	let rec_id = from
	return request_post('/action_work_done_inspect', {
		user_id: getData().id,
		record_id: rec_id,
	})
}

// 维修开始状态
export const saveStartWeixiu = (from) => {
	let rec_id = from
	return request_post('/action_work_start_repair', {
		user_id: getData().id,
		record_id: rec_id,
	})
}

// 检验开始
export const saveJianyankaishi = (from) => {
	let rec_id = from
	return request_post('/action_work_start_inspect', {
		user_id: getData().id,
		record_id: rec_id,
	})
}


// 状态回退
export const stateBackBtn = (rec_id, state) => {
	return request_post('/action_work_return', {
		user_id: getData().id,
		record_id: rec_id,
		state: state
	})
}


// 产品领用 状态
export const lingyongZhuangtai = (from) => {
	return request_post('/ticket_details_spare_parts_ling', {
		user_id: getData().id,
		beijian_id: from
	})
}

// 产品领用 状态
export const lingyongTuihui = (from) => {
	return request_post('/ticket_details_spare_parts_tui', {
		user_id: getData().id,
		beijian_id: from
	})
}

// 生成报销
export const baoxiaoShengcheng = (from) => {
	return request_post('/api_action_create_expense', {
		user_id: getData().id,
		record_id: from
	})
}